package com.sdtele.tta.operation;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.sdtele.tta.dac.Dac;
import com.sdtele.tta.models.JsonRequest;
import com.sdtele.tta.models.JsonResponse;
import com.sdtele.tta.models.Task;
import com.sdtele.tta.models.User;
import com.sdtele.tta.models.VoteOption;
import com.sdtele.tta.models.VoteScore;

public class OperationGetPieChart extends Operation {

	public JsonResponse handle(JsonRequest jsonRequest) {

		JsonResponse jres = new JsonResponse();
		User curUser = (User) request.getSession().getAttribute("user");
		long userId = curUser.getId();
		if (curUser != null) {
			Map<String, Object> lineChartMap = new HashMap<String, Object>();
			List<Task> OutTimeSusList = Dac.getInstance().getTaskofOuttime(userId);
			List<Task> InTimeSusList = Dac.getInstance().getTaskofIntime(userId);
			List<Task> OutTimeSolList = Dac.getInstance().getTaskofOuttimesloved(userId);
			List<Task> InTimeSolList = Dac.getInstance().getTaskofIntimesloved(userId);

			if (OutTimeSusList != null)
				lineChartMap.put("OutTimeSuspending", OutTimeSusList.size());
			else
				lineChartMap.put("OutTimeSuspending", 0);
			if (InTimeSusList != null)
				lineChartMap.put("InTimeSuspending", InTimeSusList.size());
			else
				lineChartMap.put("InTimeSuspending", 0);
			if (OutTimeSolList != null)
				lineChartMap.put("OutTimeSolved", OutTimeSolList.size());
			else
				lineChartMap.put("OutTimeSolved", 0);
			if (InTimeSolList != null)
				lineChartMap.put("InTimeSolved", InTimeSolList.size());
			else
				lineChartMap.put("InTimeSolved", 0);
			jres.setStatus(0);
			jres.setEntity(lineChartMap);
		} else {
			jres.setStatus(1);
			jres.setMessage("用户未登录");
		}
		return jres;
	}
}